<?php
date_default_timezone_set('Asia/Shanghai');
set_time_limit(0);
require_once './Zend/Search/lucene.php';
require_once 'CN_Lucene_Analyzer.php';

mysql_connect("192.168.188.52","cmsuser","Z0sh0wYhn7ujm");
mysql_select_db("CMS");
mysql_query("SET NAMES 'UTF8'");
$res=mysql_query('SELECT D_ID,url,Field_1049,Field_1050,Field_1055,Field_1057,Field_1065,Field_1087 FROM CMS.Table_62 order by D_ID ASC');

Zend_Search_Lucene_Analysis_Analyzer::setDefault(new CN_Lucene_Analyzer());

$index = new Zend_Search_Lucene('/www/zoshow/brand/s/bsindex20090313', true);
//$doc = new Zend_Search_Lucene_Document();

while($row = mysql_fetch_array($res)){
$doc = new Zend_Search_Lucene_Document();
$doc->addField(Zend_Search_Lucene_Field::Text('url', $row['url'],'UTF-8'));
//$doc->addField(Zend_Search_Lucene_Field::Text('title', $row['Field_1049'],'UTF-8'));
$Text=$row['Field_1049'];
$Text.="_".$row['Field_1050'].implode(" ",$strs);
$strs=str_split($row['Field_1050']);
//$docText=iconv('UTF-8','ASCII//TRANSLIT',$Text);
$doc->addField(Zend_Search_Lucene_Field::Text('contents', $Text,'UTF-8'));
$doc->addField(Zend_Search_Lucene_Field::Text('encontents', strtolower($row['Field_1050']),'UTF-8'));
$doc->addField(Zend_Search_Lucene_Field::Text('ppst', strtolower($strs[0]),'UTF-8'));
$doc->addField(Zend_Search_Lucene_Field::Text('imgurl', $row['Field_1087'],'UTF-8'));
$doc->addField(Zend_Search_Lucene_Field::Text('address', $row['Field_1057'],'UTF-8'));
$doc->addField(Zend_Search_Lucene_Field::Text('pc', $row['Field_1065'],'UTF-8'));
$index->addDocument($doc);
echo $row['D_ID']."<br>\n";
}

$index->commit();

echo 'indexer one file!';
?>